﻿using System;
using System.Collections.Generic;

namespace Snake {
    internal class GameSnake {
        private Snake snake;
        // 得分
        private int score;
        // 嘴巴里的食物
        private int food;
        // 每增长一段消耗的食物
        private int foodOfSegment;
        private const float lengthOfFood = 0.05f;

        internal GameSnake(Snake snake) {
            foodOfSegment = 10;
            this.snake = snake;
        }

        public void Eat(Food food) {
            this.score += food.getScore();
            this.food += food.getFood();

            while (this.food >= this.foodOfSegment) {
                this.food -= this.foodOfSegment;
                this.snake.AddOneLength(lengthOfFood);
            }
        }

        public Snake getSnake() {
            return snake;
        }
    }
}
